package com.ruoyi.shopInfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.shopInfo.domain.AtbShopInfoDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shopInfo.domain.AtbShopInfo;
import com.ruoyi.shopInfo.service.IAtbShopInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商铺详情信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-16
 */
@RestController
@RequestMapping("/shopInfo/shopInfo")
public class AtbShopInfoController extends BaseController
{
    @Autowired
    private IAtbShopInfoService atbShopInfoService;

    /**
     * 查询商铺详情信息列表
     */
    @PreAuthorize("@ss.hasPermi('shopInfo:shopInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(AtbShopInfo atbShopInfo)
    {
        startPage();
        List<AtbShopInfo> list = atbShopInfoService.selectAtbShopInfoList(atbShopInfo);
        return getDataTable(list);
    }

    /**
     * 导出商铺详情信息列表
     */
    @PreAuthorize("@ss.hasPermi('shopInfo:shopInfo:export')")
    @Log(title = "商铺详情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AtbShopInfo atbShopInfo)
    {
        List<AtbShopInfo> list = atbShopInfoService.selectAtbShopInfoList(atbShopInfo);
        ExcelUtil<AtbShopInfo> util = new ExcelUtil<AtbShopInfo>(AtbShopInfo.class);
        util.exportExcel(response, list, "商铺详情信息数据");
    }

    /**
     * 获取商铺详情信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('shopInfo:shopInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(atbShopInfoService.selectAtbShopInfoById(id));
    }

    /**
     * 新增商铺详情信息
     */
    @PreAuthorize("@ss.hasPermi('shopInfo:shopInfo:add')")
    @Log(title = "商铺详情信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AtbShopInfoDto atbShopInfoDto)
    {
        return toAjax(atbShopInfoService.insertAtbShopInfo(atbShopInfoDto));
    }

    /**
     * 修改商铺详情信息
     */
    @PreAuthorize("@ss.hasPermi('shopInfo:shopInfo:edit')")
    @Log(title = "商铺详情信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AtbShopInfo atbShopInfo)
    {
        return toAjax(atbShopInfoService.updateAtbShopInfo(atbShopInfo));
    }

    /**
     * 删除商铺详情信息
     */
    @PreAuthorize("@ss.hasPermi('shopInfo:shopInfo:remove')")
    @Log(title = "商铺详情信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(atbShopInfoService.deleteAtbShopInfoByIds(ids));
    }






//    @PreAuthorize("@ss.hasPermi('shopInfo:shopInfo:deleteAtbShopInfoById')")
//    @Log(title = "商铺详情信息", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{id}")
//    public AjaxResult deleteAtbShopInfoById(@PathVariable Long id)
//    {
//        return toAjax(atbShopInfoService.deleteAtbShopInfoById(id));
//    }
}
